Section 3.4.4.5
Transforming the Camera

The "translate" and "rotate" commands can re-position the camera once you've defined it.

For example:

camera { location < 0, 0, 0> direction < 0, 0, 1> up < 0, 1, 0> right < 1, 0, 0> rotate <30, 60, 30> translate < 5, 3, 4> }

In this example, the camera is created, then rotated by 30 degrees about the X axis, 60 degrees about the Y axis, and 30 degrees about the Z axis, then translated to another point in space.


Section 3.4.5
Camera Identifiers

You may declare several camera identifiers if you wish. This makes it easy to quickly change cameras. For example:

#declare Long_Lens = camera { location -z*100 direction z*50 } #declare Short_Lens = camera { location -z*50 direction z*10 } camera { Long_Lens //edit this line to change lenses look_at Here }

Section 3.5
Objects

Objects are the building blocks of your scene. There are 20 different types of objects supported by POV-Ray. Thirteen of them are finite solid primitives, 4 are finite patch primitives, 5 are infinite solid polynomial primitives, 3 are types of Constructive Solid Geometry and one is a specialized object that is a light source.

The basic syntax of an object is a keyword describing its type, some floats, vectors or other parameters which further define its location and/or shape and some optional object modifiers such as texture, pigment, normal, finish, bounding, clipping or transformations.

The texture describes what the object looks like, i. e. its material. Textures are combinations of pigments, normals and finishes. Pigment is the color or pattern of colors inherent in the material. Normal is a method of simulating various patterns of bumps, dents, ripples or waves by modifying the surface normal vector. Finish describes the reflective and refractive properties of a material.

Bounding shapes are finite, invisible shapes which wrap around complex, slow rendering shapes in order to speed up rendering time. Clipping shapes are used to cut away parts of shapes to expose a hollow interior. Transformations tell the ray tracer how to move, size or rotate the shape and/or the texture in the scene.


Section 3.5.1
Finite Solid Primitives

There are 13 different solid finite primitive shapes: blob, box, cone, cylinder, fractal, height field, lathe, sphere, superellipsoid, surface of revolution, text object and torus. These have a well-defined "inside" and can be used in CSG (see section "Constructive Solid Geometry" ). They are finite and respond to automatic bounding.

Section 3.5.1.1
Blob


A blob.

Blobs are an interesting and flexible object type. Mathematically they are iso-surfaces of scalar fields, i.e. their surface is defined by the strength of the field in each point. If this strength is equal to a threshold value you're on the surface otherwise you're not.

Picture each blob component as an object floating in space. This object is "filled" with a field that has its maximum at the center of the object and drops off to zero at the object's surface. The field strength of all those components are added together to form the field of the blob. Now POV-Ray looks for points where this field has a given value, the "threshold" value. All these points form the surface of the blob object. Points with a greater field than the threshold value are considered to be inside while points with a smaller field are outside.

There's another, simpler way of looking at blobs. They can be seen as a union of "flexible" components that attract or repel each other to form a "blobby" organic looking shape. The components' surfaces actually stretch out smoothly and connect as if they were made of honey or something like that.

A blob is made up of spherical and cylindrical components and is defined as follows:

blob { threshold THRESHOLD_VALUE cylinder { <END1>, <END2>, RADIUS, [ strength ] STRENGTH } sphere { <CENTER>, RADIUS, [ strength ] STRENGTH } [ component STRENGTH, RADIUS, <CENTER> ] [ hierarchy FLAG ] [ sturm ] }

The threshold value is the total field strength value that POV-Ray is looking for. By following the ray out into space and looking at how each blob component affects the ray, POV-Ray will find the points in space where the field strength is equal to the threshold value. The following list shows some things you should know about the threshold value.

1) The threshold value must be positive.
2) A component disappears if the threshold value is greater than its strength.
3) As the threshold value gets larger the surface you see gets closer to the centers of the components.
4) As the threshold value gets smaller, the surface you see gets closer to the surface of the components.

Cylindrical components are specified by the keyword "cylinder" giving a cylinder formed by the base <END1>, the apex <END2> and the radius. This cylinder has hemispherical caps at the base and apex. Spherical components are specified by the keyword "sphere" forming a sphere at <CENTER> with the gives radius. Each component can be individually translated, rotated, scaled and textured. The complete syntax for the cylindrical and spherical components is:

sphere { <CENTER>, RADIUS, [strength] STRENGTH [ translate <VECTOR> ] [ rotate <VECTOR> ] [ scale <VECTOR> ] TEXTURE_MODIFIERS } cylinder { <END1>, <END2>, RADIUS, [strength] STRENGTH [ translate <VECTOR> ] [ rotate <VECTOR> ] [ scale <VECTOR> ] TEXTURE_MODIFIERS }

By unevenly scaling a spherical component you can create ellipsoidal components. The component keyword gives a spherical component and is only used for compatibility with earlier POV-Ray versions.

The "strength" parameter is a float value specifying the field strength at the center of the object. The strength may be positive or negative. A positive value will make that component attract other components while a negative value will make it repel other components. Components in different, separate blob shapes do not affect each other.

You should keep the following things in mind.

1) The strength value may be positive or negative. Zero is a bad value, as the net result is that no field was added --- you might just as well have not used this component.
2) If strength is positive, then POV-Ray will add the component's field to the space around the center of the component. If this adds enough field strength to be greater than the "threshold" value you will see a surface.
3) If the strength value is negative, then POV-Ray will subtract the component's field from the space around the center of the component. This will only do something if there happen to be positive components nearby. What happens is that the surface around any nearby positive components will be dented away from the center of the negative component.

The components of each blob object are internally bounded by a spherical bounding hierarchy to speed up blob intersection tests and other operations. By using the optional keyword "hierarchy" you can switch this hierarchy off.

An example of a three component blob is:

blob { threshold 0.6 sphere { <.75, 0, 0>, 1, 1 } sphere { <-.375, .64952, 0>, 1, 1 } sphere { <-.375, -.64952, 0>, 1, 1 } scale 2 }

If you have a single blob component then the surface you see will just look like the object used, i.e. a sphere or a cylinder, with the surface being somewhere inside the surface specified for the component. The exact surface location can be determined from the blob equation listed below (you will probably never need to know this, blobs are more for visual appeal than for exact modeling).

For the more mathematically minded, here's the formula used internally by POV-Ray to create blobs. You don't need to understand this to use blobs.

The formula used for a single blob component is:

density = strength * (1 - radius^2)^2

This formula has the nice property that it is exactly equal to STRENGTH at the center of the component and drops off to exactly 0 at a distance of RADIUS from the center of the component. The density formula for more than one blob component is just the sum of the individual component densities:

density = density1 + density2 + ...

Blobs can be used in CSG shapes and they can be scaled, rotated and translated. Because they are finite they respond to automatic bounding. The calculations for blobs must be very accurate. If this shape renders improperly you may add the keyword "sturm" after the last component to use POV-Ray's slower-yet-more-accurate Sturmian root solver.


Section 3.5.1.2
Box


A box.

A simple box can be defined by listing two corners of the box like this:

box { <CORNER1>, <CORNER2> }

Where <CORNER1> and <CORNER2> are vectors defining the x, y, z coordinates of opposite corners of the box.

Note that all boxes are defined with their faces parallel to the coordinate axes. They may later be rotated to any orientation using a rotate parameter.

Each element of CORNER1 should always be less than the corresponding element in CORNER2. If any elements of CORNER1 are larger than CORNER2, the box will not appear in the scene.

Boxes are calculated efficiently and make good bounding shapes. Because they are finite they respond to automatic bounding. As with all shapes, they can be translated, rotated and scaled.


Section 3.5.1.3
Cone


A cone.

A finite length cone or a frustum (a cone with the point cut off) may be defined by.

cone { <END1>, RADIUS1, <END2>, RADIUS2 }

Where <END1> and <END2> are vectors defining the x, y, z coordinates of the center of each end of the cone and RADIUS1 and RADIUS2 are float values for the radius of those ends.

Like a cylinder, normally the ends of a cone are closed by flat planes which are parallel to each other and perpendicular to the length of the cone. Adding the optional keyword "open" after RADIUS2 will remove the end caps and results in a tapered hollow tube like a megaphone or funnel.

Because they are finite they respond to automatic bounding. As with all shapes, they can be translated, rotated and scaled.


Section 3.5.1.4
Cylinder


A cylinder.

A finite length cylinder with parallel end caps may be defined by.

cylinder { <END1>, <END2>, RADIUS }

Where <END1> and <END2> are vectors defining the x, y, z coordinates of the center of each end of the cylinder and RADIUS is a float value for the radius.

Normally the ends of a cylinder are closed by flat planes which are parallel to each other and perpendicular to the length of the cylinder. Adding the optional keyword "open" after the radius will remove the end caps and results in a hollow tube.

Because they are finite they respond to automatic bounding. As with all shapes, they can be translated, rotated and scaled.


Section 3.5.1.5
Height Field


A height field.

Height fields are fast, efficient objects that are generally used to create mountains or other raised surfaces out of hundreds of triangles in a mesh. The height field syntax is:

hfield { FILE_TYPE "FILENAME" [ hierarchy BOOL ] [ smooth BOOL ] [ water_level FLOAT ] }

A height field is essentially a one unit wide by one unit long square with a mountainous surface on top. The height of the mountain at each point is taken from the color number or palette index of the pixels in a graphic image file. The maximum height is one. That corresponds to the maximum possible color or palette index value in the image file.


The size and orientation of an un-scaled height field.

The mesh of triangles corresponds directly to the pixels in the image file. Each square formed by four neighboring pixels is divided into two triangles. An image with a resolution of NxM pixels has (N-1)x(M-1) squares that are divided into 2x(N-1)x(M-1) triangles.

The resolution of the height field is influenced by two factors: the resolution of the image and the resolution of the color/index values. The size of the image determines the resolution in the x- and z-direction. A larger image uses more triangles and looks smoother. The resolution of the color/index value determines the resolution along the y-axis. A height field made from an 8 bit image can have 256 different height levels while one made from a 16 bit image can have up to 65536 different height levels. Thus the second height field will look much smoother in the y-direction if the height field is created appropriately.

The size/resolution of the image does not affect the size of the height field. The un-scaled height field size will always be 1x1. Higher resolution image files will create smaller triangles, not larger height fields.

There are six or possibly seven types of files which can define a heightfield, as follows:

height_field { gif "filename.gif" } height_field { pgm "filename.pgm" } height_field { png "filename.png" } height_field { pot "filename.pot" } height_field { ppm "filename.ppm" } height_field { sys "filename.???" } height_field { tga "filename.tga" }

The image file used to create a height field can be a GIF, TGA, POT, PNG, PGM, PPM, and possibly a system specific (Windows BMP or Macintosh Pict) format file. The GIF, PNG, PGM, and possibly system format files are the only ones that can be created using a standard paint program. Though there are paint programs for creating TGA image files they won't be of much use for creating the special 16 bit TGA files used by POV-Ray (see below and "HF_Gray_16" for more details).

In an image file like GIF that uses a color palette the color number is the palette index at a given pixel. Use a paint program to look at the palette of a GIF image. The first color is palette index zero, the second is index one, the third is index two, and so on. The last palette entry is index 255. Portions of the image that use low palette entries will result in lower parts of the height field. Portions of the image that use higher palette entries will result in higher parts of the height field.

Height fields created from GIF files can only have 256 different height levels because the maximum number of colors in a GIF file is 256.

The color of the palette entry does not affect the height of the pixel. Color entry 0 could be red, blue, black, or orange, but the height of any pixel that uses color entry 0 will always be 0. Color entry 255 could be indigo, hot pink, white, or sky blue, but the height of any pixel that uses color entry 255 will always be 1.

You can create height field GIF images with a paint program or a fractal program like "Fractint". You can usually get Fractint from most of the same sources as POV-Ray.

A POT file is essentially a GIF file with a 16 bit palette. The maximum number of colors in a POT file is 65536. This means a POT height field can have up to 65536 possible height values. This makes it possible to have much smoother height fields. Note that the maximum height of the field is still 1 even though more intermediate values are possible.

At the time of this writing, the only program that created POT files was a freeware IBM-PC program called Fractint. POT files generated with this fractal program create fantastic landscapes.

The TGA and PPM file formats may be used as a storage device for 16 bit numbers rather than an image file. These formats use the red and green bytes of each pixel to store the high and low bytes of a height value. These files are as smooth as POT files, but they must be generated with special custom-made programs. Several programs can create TGA heightfields in the format POV uses, such as "gforge", and "Terrain Maker".

PNG format heightfields are usually stored in the form of a grayscale image, with black corresponding to lower and white to higher parts of the height field. Because PNG files can store up to 16 bits in grayscale images, they will be as smooth as TGA and PPM images. Since they are grayscale images, you will be able to view them with a regular image viewer. Gforge can create 16-bit heightfields in PNG format. Color PNG images will be used in the same way as TGA and PPM images.

SYS format is a platform specific file format. See your platform specific documentation for details.

An optional "water_level" parameter may be added after the file name. It consists of the keyword "water_level" followed by a float value telling the program to ignore parts of the height field below that value. The default value is zero, and legal values are between zero and one. For example, "water_level .5" tells POV-Ray to only render the top half of the height field. The other half is "below the water" and couldn't be seen anyway. This term comes from the popular use of height fields to render landscapes. A height field would be used to create islands and another shape would be used to simulate water around the islands. A large portion of the height field would be obscured by the "water" so the "water_level" parameter was introduced to allow the ray-tracer to ignore the unseen parts of the height field. Water_level is also used to "cut away" unwanted lower values in a height field. For example, if you have an image of a fractal on a solid colored background, where the background color is palette entry 0, you can remove the background in the height field by specifying, "water_level .001"

Normally height fields have a rough, jagged look because they are made of lots of flat triangles. Adding the keyword "smooth" causes POV-Ray to modify the surface normal vectors of the triangles in such a way that the lighting and shading of the triangles will give a smooth look. This may allow you to use a lower resolution file for your height field than would otherwise be needed. However, smooth triangles will take longer to render.

In order to speed up the intersection tests an one-level bounding hierarchy is available. By default it is always used but it can be switched off to eventually imrpove the rendering speed for small height fields (i.e. low resolution images).

Height fields can be used in CSG shapes and they can be scaled, rotated and translated. Because they are finite they respond to automatic bounding.


Next Section
Table Of Contents